import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { orderVO, orderForm, orderQuery } from '@/api/event/order/types';

/**
 * 查询工单列表
 * @param query
 * @returns {*}
 */

export const listorder = (query?: orderQuery): AxiosPromise<orderVO[]> => {
  return request({
    url: '/event/order/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工单详细
 * @param workOrderId
 */
export const getorder = (workOrderId: string | number): AxiosPromise<orderVO> => {
  return request({
    url: '/event/order/' + workOrderId,
    method: 'get'
  });
};

/**
 * 新增工单
 * @param data
 */
export const addorder = (data: orderForm) => {
  return request({
    url: '/event/order',
    method: 'post',
    data: data
  });
};

/**
 * 修改工单
 * @param data
 */
export const updateorder = (data: orderForm) => {
  return request({
    url: '/event/order',
    method: 'put',
    data: data
  });
};

/**
 * 删除工单
 * @param workOrderId
 */
export const delorder = (workOrderId: string | number | Array<string | number>) => {
  return request({
    url: '/event/order/' + workOrderId,
    method: 'delete'
  });
};

/**
 * 接单
 * @param workOrderId
 */
export const receiveorder = (workOrderId: string | number | Array<string | number>) => {
  return request({
    url: '/event/order/receive/' + workOrderId,
    method: 'get'
  });
};
/**
 * 接单
 * @param workOrderId
 */
export const acceptOrders = (workOrderId: string | number)=> {
  return request({
    url: '/event/order/acceptOrders/' + workOrderId,
    method: 'get'
  });
};

/**
 * 关闭工单
 * @param workOrderId
 */
export const close = (data)=> {
  return request({
    url: '/event/order/close',
    method: 'post',
    data: data
  });
};

/**
 * 转单
 */
export const transferOrder = (data)=> {
  return request({
    url: '/event/order/transferOrder',
    method: 'post',
    data: data
  });
};

/**
 * 完成工单
 * @param workOrderId
 */
export const complete = (data)=> {
  return request({
    url: '/event/order/complete',
    method: 'post',
    data: data
  });
};

/**
 * 退单工单
 * @param workOrderId
 */
export const refundOrder = (data)=> {
  return request({
    url: '/event/order/refundOrder',
    method: 'post',
    data: data
  });
};
